Skip to content

Conversation

@JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented Jan 23, 2026

@vstinner
Copy link
Member

I closed my PR #144177 since this one is more complete.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I just left minor suggestions.

Comment on lines +945 to 946
"%.400s got multiple values for argument %R",
Py_TYPE(self)->tp_name, key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are modifying the error message, you must use the safer %T format:

Suggested change
"%.400s got multiple values for argument %R",
Py_TYPE(self)->tp_name, key);
"%T got multiple values for argument %R",
self, key);

Same remark for the two other changes below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this changes the error message to include the module name:

$ python3.14 -Wall -c 'import ast; ast.Name(idx=3)'
<string>:1: DeprecationWarning: Name.__init__ got an unexpected keyword argument 'idx'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15.
<string>:1: DeprecationWarning: Name.__init__ missing 1 required positional argument: 'id'. This will become an error in Python 3.15.
$ ./python.exe -Wall -c 'import ast; ast.Name(idx=3)'
<string>:1: DeprecationWarning: ast.Name.__init__ got an unexpected keyword argument 'idx'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15.
<string>:1: DeprecationWarning: ast.Name.__init__ missing 1 required positional argument: 'id'. This will become an error in Python 3.15.

I feel like that's a change we should only make in 3.15, not in the bugfix releases.

Why is %T safer?

Co-authored-by: Victor Stinner <vstinner@python.org>
@JelleZijlstra JelleZijlstra merged commit 639c1ad into python:main Jan 26, 2026
47 checks passed
@miss-islington-app
Copy link

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@JelleZijlstra JelleZijlstra deleted the ast-str-kwarg branch January 26, 2026 01:29
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 26, 2026
…pythonGH-144178)

(cherry picked from commit 639c1ad)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
@miss-islington-app
Copy link

Sorry, @JelleZijlstra, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 639c1ad4f1ef5c2409a62fa8ed16e6aa3a6f9ab8 3.13

@bedevere-app
Copy link

bedevere-app bot commented Jan 26, 2026

GH-144227 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.13 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants